using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using StudyCompanion.Commons.Result;
using StudyCompanion.Core.API;
using StudyCompanion.Dto.Web;
using StudyCompanion.IServices;

namespace StudyCompanion.WebApi.Controllers;

/// <summary>
///     注册服务
/// </summary>
[Route("api/[controller]")]
[ApiController]
[AllowAnonymous]
public class WebController : ApiController
{
    private readonly IWebRegisService _webRegis;

    /// <summary>
    ///     注册服务
    /// </summary>
    /// <param name="userService"></param>
    public WebController(IWebRegisService webRegis)
    {
        _webRegis = webRegis;
    }

    /// <summary>
    ///     H5注册
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpPost("AddUser")]
    public async Task<CommonResult> AddUser(AddUserDto dto)
    {
        var data = await _webRegis.AddUser(dto);
        return data.Item1 ? Success() : Problem(data.Item2);
    }
}